#ifndef OGREREFAPPSUPPORTSPOTCALCULATOR
#define OGREREFAPPSUPPORTSPOTCALCULATOR

//------------------------------------------------------------------------
//
//  Name:   SupportSpotCalculator.h
//
//  Desc:   Class to determine the best spots for a suppoting soccer
//          player to move to.
//
//  Author: Mat Buckland 2003 (fup@ai-junkie.com)
//
//------------------------------------------------------------------------

#include "OgreRefAppPrerequisites.h"

namespace OgreRefApp
{

    class PlayerBase;
    class Goal;
    class SoccerBall;
    class SoccerTeam;
    class Regulator;



//------------------------------------------------------------------------

    class SupportSpotCalculator
    {
    private:

        //a data structure to hold the values and positions of each spot
        struct SupportSpot
        {

            Ogre::Vector3  m_vPos;

            Ogre::Real    m_dScore;

            SupportSpot(Ogre::Vector3 pos, Ogre::Real value):m_vPos(pos),
                    m_dScore(value)
            {}
        };

    private:


        SoccerTeam*               m_pTeam;

        std::vector<SupportSpot>  m_Spots;

        //a pointer to the highest valued spot from the last update
        SupportSpot*              m_pBestSupportingSpot;

        //this will regulate how often the spots are calculated (default is
        //one update per second)
        Regulator*                m_pRegulator;

    public:

        SupportSpotCalculator(int numX,
                              int numY,
                              SoccerTeam* team);

        ~SupportSpotCalculator();


        //this method iterates through each possible spot and calculates its
        //score.
        Ogre::Vector3  DetermineBestSupportingPosition();

        //returns the best supporting spot if there is one. If one hasn't been
        //calculated yet, this method calls DetermineBestSupportingPosition and
        //returns the result.
        Ogre::Vector3  GetBestSupportingSpot();
    };

}
#endif
